package com.johnny.xia.util.crawler;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class JsoupUtil {

	public static void main(String[] args) throws IOException {
		Document doc = Jsoup
				.connect(
						"http://www.qyl71.com/60776/%E8%A4%AA%E4%B8%8B%E7%99%BD%E4%B8%9D%E8%BF%9E%E8%A1%A3%E8%A3%99%E5%A8%87%E5%AB%A9%E4%BA%BA%E5%A6%BB%E5%86%85%E8%A3%A4-%E4%BB%BB%E9%81%93%E5%85%B7%E7%8B%82%E6%8F%92%E8%88%94%E7%A1%AC%E5%A4%A7%E9%B8%A1%E5%B7%B4%E7%AB%99%E7%AB%8B%E5%90%8E%E5%85%A5/")
				.get();

		Element element = doc.getElementById("player");
		if (element != null) {
			Elements es = element.children();
			for (Element e : es) {
				if (e.hasAttr("src")) {
					System.out.println(e.attr("src"));
				}
			}

		}

	}

	public static String getVideoSrc(String html) {
		Document doc = Jsoup.parse(html);
		Element element = doc.getElementById("player");
		if (element != null) {
			Elements es = element.children();
			for (Element e : es) {
				if (e.hasAttr("src")) {
					System.out.println(e.attr("src"));
					return e.attr("src");
				}
			}
		}
		
		return null;
	}

}
